package com.key.controller.admin.setting;

import com.key.common.R;
import com.key.common.vo.UserVO;
import com.key.entity.ModelLabel;
import com.key.service.LabelService;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
@RequestMapping("/label")
@Api(value = "模板标签设置",tags = "模板标签设置接口API")
public class LabelController {
    @Autowired
    private LabelService labelService;
    @RequestMapping(value = "/findLeft",method = RequestMethod.GET)
    @ApiOperation(value = "显示右边所有字段",notes = "查询右边表字段",httpMethod = "get", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="登录成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findLeft(){

        return labelService.findAllLeft();
    }

    @RequestMapping(value = "/addLabel",method = RequestMethod.POST)
    @ApiOperation(value = "提交图片模板",notes = "添加图片模板",httpMethod = "post", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="登录成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addLabel(@RequestBody @ApiParam(name = "ids",value = "右边资产字段id数组",required = true)List<Integer> ids){

        return labelService.addPhoto(ids);
    }

    @RequestMapping(value = "/commit",method = RequestMethod.POST)
    @ApiOperation(value = "提交自定义模板",notes = "添加一条模板数据",httpMethod = "post", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="登录成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R commit(@RequestBody @ApiParam(name = "modelLabel",value = "模板实体",required = true)ModelLabel modelLabel){

        return labelService.commitLabel(modelLabel);
    }

    @RequestMapping(value = "/findPhoto",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有图片",notes = "查询图片表",httpMethod = "get", response = R.class)
    @ApiImplicitParam(name = "type",value = "图片类型",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="登录成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findPhoto(@RequestParam("type") Integer type){

        return labelService.findPhoto(type);
    }

    @RequestMapping(value = "/deletePhotoLabel",method = RequestMethod.GET)
    @ApiOperation(value = "选择图片后删除",notes = "删除图片",httpMethod = "get", response = R.class)
    @ApiImplicitParam(name = "photoId",value = "图片id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="登录成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deletePhotoLabel(@RequestParam("photoId") Integer photoId){

        return labelService.deletePhotoLabel(photoId);
    }
}
